// Christophe Coenraets, christophe@coenraets.org - http://coenraets.org
package com.salesbuilder.control
{
	import mx.collections.ArrayCollection;
	import mx.rpc.AsyncToken;
	import mx.rpc.Responder;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.http.HTTPService;

	/*
		Caches lookup tables for the application. This would typically be read
		from the database instead of being hardcoded. 		
	*/
	public class Params
	{
		[Bindable] public var states:ArrayCollection;
		
		public static var instance:Params;
		
		[Bindable] public var accountTypes:ArrayCollection = new ArrayCollection([
			{data: 0, label:"Select"}, 
			{data: 1, label:"Customer"},
			{data: 2, label:"Partner"},
			{data: 3, label:"Competitor"}]); 

		[Bindable] public var industries:ArrayCollection = new ArrayCollection([
			{data: 0, label:"Select"}, 
			{data: 1, label:"Aerospace"}, 
			{data: 2, label:"Airlines"}, 
			{data: 3, label:"Automobile"}, 
			{data: 4, label:"Biotechnology"}, 
			{data: 5, label:"Computer Hardware"},
			{data: 6, label:"Computer Software"},
			{data: 7, label:"Conglomerates"},
			{data: 8, label:"Financial Services"},
			{data: 9, label:"Food and Beverage"},
			{data: 10, label:"Government"},
			{data: 11, label:"Telecom"}
			]);

		[Bindable] public var owners:ArrayCollection = new ArrayCollection([
			{data: 0, label:"Select"}, 
			{data: 1, label:"Christophe Coenraets"},
			{data: 2, label:"Lloyd Hill"},
			{data: 3, label:"Brian Rull"}]); 
		
		public function Params()
		{
			var srv:HTTPService = new HTTPService();
			srv.url = "data/states.xml";
			var token:AsyncToken = srv.send();
			token.addResponder(new Responder(
				function (event:ResultEvent):void
				{
					states = event.result.states.state;
				},
				function (event:FaultEvent):void
				{
					//Alert.show("Chinh la tui, " + event.fault.faultString);
					RIALogger.error(this, event.fault.faultString);
				}
			));
			instance = this;
		}

	}
}